Unit Enemies;

{$mode objfpc}{$H+}

Interface

Uses
  ItemProperties,
  EnA,
  Crt;

Var
  EHP, ESTR,
  EXPReward,
  GoldReward : Integer;

Procedure WeakEnemy(Level : Integer; Var EHP, ESTR, EXPReward, GoldReward : Integer);
Procedure MediumEnemy(Level : Integer; Var EHP, ESTR, EXPReward, GoldReward : Integer);
Procedure HardEnemy(Level : Integer; Var EHP, ESTR, EXPReward, GoldReward : Integer);
Procedure EnemySpawn(Level : Integer; Var EHP, ESTR, EXPReward : Integer);
Function EnemyAttack(CombatAction : Char; ESTR : Integer) : Integer;

Implementation

//WEAK ENEMY
Procedure WeakEnemy(Level : Integer; Var EHP, ESTR, EXPReward, GoldReward : Integer);
Var
  IncreaseHP, IncreaseSTR : Integer;

Begin
  IncreaseHP := 50 * Level; //Enemy HP increase per player level
  IncreaseSTR := (1 * Level) + 2; //Enemy damage increase per player level

  EHP := 50 + IncreaseHP;
  ESTR := 1 + IncreaseSTR;
  EXPReward := 1 + Level;
  GoldReward := Random(20) + 5;
end;

//MEDIUM ENEMY
Procedure MediumEnemy(Level : Integer; Var EHP, ESTR, EXPReward, GoldReward : Integer);
Var
  IncreaseHP, IncreaseSTR : Integer;

Begin
  IncreaseHP := 50 * Level;
  IncreaseSTR := (2 * Level) + 2;

  EHP := 90 + IncreaseHP;
  ESTR := 1 * IncreaseSTR;
  EXPReward := 2 + Level;
  GoldReward := Random(30) + 15;
end;

//HARD ENEMY
Procedure HardEnemy(Level : Integer; Var EHP, ESTR, EXPReward, GoldReward : Integer);
Var
  IncreaseHP, IncreaseSTR : Integer;

Begin
  IncreaseHP := 50 * Level;
  IncreaseSTR := (3 * Level) + 2;

  EHP := 140 + IncreaseHP;
  ESTR := 1 * IncreaseSTR;
  EXPReward := 3 + Level;
  GoldReward := Random(50) + 25;
end;


//ENEMY SPAWNER
Procedure EnemySpawn(Level : Integer; Var EHP, ESTR, EXPReward : Integer);
Var
  Enemy : Integer;

Begin
  Randomize;
  Randomize;
  Enemy := Random(3) + 1;

  If Enemy = 1 then
    Begin
      WeakEnemy(Level, EHP, ESTR, EXPReward, GoldReward);
      Writeln('A Weak enemy appears!');
      Writeln('Press enter to continue');
      Readln;
      Clrscr;
    end;

  If Enemy = 2 then
    Begin
      MediumEnemy(Level, EHP, ESTR, EXPReward, GoldReward);
      Writeln('A Medium enemy appears!');
      Writeln('Press enter to continue');
      Readln;
      Clrscr;
    end;

  If Enemy = 3 then
    Begin
      HardEnemy(Level, EHP, ESTR, EXPReward, GoldReward);
      Writeln('A Hard enemy appears!');
      Writeln('Press enter to continue');
      Readln;
      Clrscr;
    end;

end;

Function EnemyAttack(CombatAction : Char; ESTR : Integer) : Integer;
Var
  Damage, Attack : Integer;

 Begin
  Randomize;
  Attack := Random(10 + 1);
  If Attack <= 9 then
    Begin
      Damage := Random(20 + 10) + ESTR;
      If CombatAction = #51 then
        Begin
          Damage := Damage div 2;
          EnemyAttack := Damage
          end else
            EnemyAttack := Damage;
    end else
      Begin
        If Ailment1 = '' then
          Ailment1 := 'Poison';
        If (Ailment2 = '') and (Ailment1 = '') then
          Ailment2 := 'Poison';
        EnemyAttack := 0;
      end;
  end;

end.
